package com.u.finance.loans.controller;


import com.u.finance.loans.entity.Loans;
import com.u.finance.loans.model.LoanApplyForm;
import com.u.finance.loans.service.ILoansService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Alex Wu
 * @since 2025-03-28
 */
@RestController
@RequestMapping("/loans")
public class LoansController {

    @Autowired
    private ILoansService loanService;

    @GetMapping("/quota-limit/userId/{userId}")
    public Long  queryLimit(@PathVariable String userId) {
        Long quotaLimit = loanService.getQuotaLimit(userId);
        return quotaLimit;
    }

    @PostMapping("/apply")
    public Boolean apply(@RequestBody LoanApplyForm loanApplyForm) {
        Boolean result = loanService.applyLoan(loanApplyForm);
        return result;
    }
}
